package com.demostic.demostic_test.utils;

import android.content.Context;
import android.widget.Toast;

import com.demostic.demostic_test.R;

public class ToastUtils {
    private static Toast toast;

    public static void showToast(Context context, String msg) {
        if (toast == null) {
            toast = Toast.makeText(context, msg, 0);
        } else {
            toast.setText(msg);
        }
        toast.show();
    }

    public static void showErrorToast(Context context, int code) {
        String msg = context.getString(R.string.consume_aty_conn_timeout);
        switch (code) {
            case 1986:
                msg = context.getString(R.string.consume_aty_noWifi_conn);
                break;
            case 1993:
                msg = context.getString(R.string.consume_aty_conn_timeout);
                break;
            case 3501:
                msg = context.getString(R.string.login_aty_account_no);
                break;
            case 3504:
                msg = context.getString(R.string.login_aty_pw_error);
                break;
            case 3807:
                msg = context.getString(R.string.clock_aty_dev_offline);
                break;
        }
        if (toast == null) {
            toast = Toast.makeText(context, msg, 0);
        } else {
            toast.setText(msg);
        }
        toast.show();
    }
}
